<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<? 
require_once 'includes/funciones.php';
include ("seguridad.php");
conexion();
?>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Registrar Usuario</title>


        <link type="text/css"  href="plugins/jq_ui/css/custom-theme/jquery-ui-1.8.14.custom.css" rel="stylesheet"/> 
        <script src="plugins/jq_ui/js/jquery-1.4.4.min.js"></script>
	<script  src="plugins/jq_ui/development-bundle/ui/jquery.ui.widget.js"></script>
	<script src="plugins/jq_ui/development-bundle/ui/jquery.ui.button.js"></script>
	
<script type="text/javascript">
$(function()
    {
	$( "#boton1" )
        	.button()
    })
</script>
<script type="text/javascript"  src="plugins/jquery_validate/jquery.validate.js"></script>
<script>
  $(document).ready(function(){
		
	$("#userForm").validate({
		rules: {			
			nombre: {
				required: true
				},

                     apellido: {
                            required: true
                            },
			mail: {
				required: true,
				email: true
			},
                        mail2: {
				required: true,
				email: true,
                                equalTo: "#mail"
                                
			},
                       nombreus: {
                            required: true,
                            minlength: 4
                            },
			pass: {
				required: true,
				minlength: 5
			},
			pass2: {
				required: true,
				minlength: 5,
				equalTo: "#pass"
			}

		},
		messages: {
			nombre: {
				required: "*"
				
			},
                        apellido: {
				required: "*"
				
			},
                        mail: {
                               required: "*",
                               email:"<br>Ingrese una direccion de email valida"},
                        mail2: {
				required: "*",
                                email:"<br>Ingrese una direccion de email valida",
				equalTo: "<br>La Direciones de mail no son iguales "
			},
                        nombreus: {
				required: "*",
				minlength: "<br>Debe tener mas de 4 caracteres"
			},

			pass: {
				required: "*",
				minlength: "<br>Debe tener mas de 5 caracteres"
			},
			pass2: {
				required: "*",
				minlength: "<br>Debe tener mas de 5 caracteres",
				equalTo: "<br>Las contraseñas no coinciden"
			}
			
			
		}
	});
	
  });
</script>
<script language="JavaScript"  type="text/JavaScript">
    $(document).ready(function(){
        $("#org").change(function(event){
            var id = $("#org").find(':selected').val();
                $("#area").load('selectarea.php?var='+id);
				$("#resultado").load('borg.php?var='+id);

        });

    });
</script>

<script language="JavaScript"  type="text/JavaScript">
    $(document).ready(function(){
        $("#area").change(function(event){
             var idm = $("#area").find(':selected').val();  
            $("#resultado").load('barea.php?var='+idm);
        });

    });

</script>

<style type="text/css">
    
.error{
    color: #D8000C;
    font-size:13px;
    border-color:#F00;
	padding-left:5px;}
    /*margin-left: 5px; /*/

#log{
width:420px;

font-family:Arial, Helvetica, sans-serif;
font-size:14px;
background-image:url(regu.JPG);

background-repeat:no-repeat;
margin:150px auto 0 auto; 
}

#titulo{
margin-top:4px;
font-weight:bold;
margin-left:40px;
color:#FFFFFF;
}

#form{
font-weight:bold;
margin-top: 5px;
margin-left:80px;
padding-left:40;
}

.imput{
width:270px;}
</style>
</head>


<body>
<div id="log"><br />
  <div id="titulo"> <b>Registrar Usuario </b></div>
  <br />
<div id="form">
  <form id="userForm" name="userForm" method="post"  action="">
    <label>Nombre<br />
    <input  class="imput" name="nombre" type="text" size="40" />   </label>
    <br />
    
	 <label>Apellido<br />
      <input class="imput" name="apellido" type="text" size="40" />
      </label>  
     <br />
     	
        <label>Nombre de Usuario<br />
        <input class="imput" name="nombreus" type="text" size="40" />
        </label>
        <br /><br>
	 <label>E-mail<br />
      <input class="imput" name="mail" id="mail" type="text" size="40" />
      </label>  
     <br />
        <label>Confirmarmar E-mail<br />
        <input class="imput" name="mail2" id="mail2"type="text" size="40" />
        </label> 
        
  <br /> <br />
        <label>Contraseña<br />
        <input class="imput" name="pass"  id="pass" type="password" size="40" />
        </label> 
      
		<br />
        <label>Repetir Contraseña <br />
        <input class="imput" name="pass2" id="pass2" type="password" size="40" />
        </label>
        <br />
       <br />

      <label>Organizacion a la pretenece  <br />
      </label>
        <label>
        <select class="imput"name="org" id="org">
            <option value ="">Seleccione Organizacion</option>
			    <?php
				$concla= mysql_query("select o.id,o.nombre  from samptyt.organizacion as o;");
                while($rowconcla=mysql_fetch_array($concla))
                    {
                        echo '<option value="'.$rowconcla['id'].'">'.$rowconcla['nombre'].' </option>';
                    }
                    ?>
					</select>
        </label>
        <br />
      
      <label>Area a la que pretenese <br />
      <select  class="imput" name="area" id= "area">
	  	 <option>Seleccione Area</option>
      </select>
      </label>
		<br />
		<br />
        <label style="margin:180px;">
     <input name="boton" type="hidden" id="boton" value="1"></input>
      <input id="boton1" style=" font-size:12px; color: #2E6E9E; "  type="submit" name="Submit" value="Registrarse" />
    </label>
                <br><br></br><br></br>
    </form>
	  
 </div><p  style=" margin-left:40px;
 margin-bottom:40px;
 float: Arial, sans-serif;
font-size:12px;
 "><a href="reg_usser.php"></a></p>
 <br /></div>
   


 <?php


//require_once 'seguridad.php';

if($_POST['boton']==1){
   
///####################################///
///##########CARGAR area#############///
///####################################///
//echo"es el  buton"; 


       $nombre=($_POST['nombre']);
       $apellido=($_POST['apellido']);
       $nombreus=($_POST['nombreus']);
       $mail=($_POST['mail']);
       $pass=($_POST['pass']);
        $org=sqlint($_POST['org']);
        $area=sqlint($_POST['area']);
       ///####################################///

 
        
       $campos="`nombre` ,
                `apellido` ,
                `email` ,
                `nombre_us` ,
                `pass` ,
                `org_id` ,
                `area_id`";
       
         $valores="'$nombre','$apellido','$mail','$nombreus','$pass','$org','$area'";
        
         sqlinsert("`samptyt`.`usuario`", $campos, $valores);
         ///####################################///

         //echo'<script>location.href="capavermas.php?var='.$id_capa.'";</script>';
}?>
</body>
</html>
